sound_pool object
This method will update the start values of the sound.
bool update_sound_start_values(int slot, float start_pan, float start_volume, float start_pitch)
Parameters:
slot
The slot of the sound to update.
start_pan
The new starting pan of the sound.
start_volume
The new starting volume of the sound.
start_pitch
The new starting pitch of the sound.
Return value:
true on success, false on failure.
Remarks:
All the position calculations will be done relative to the values you specify for start_pan and start_volume, and for 2d sounds this also applies to start_pitch. For 1d sounds, the pitch will simply be set to the value specified and will then remain unchanged.
The parameters of this function expect absolute values.
Please note: When dealing with sound slots, be sure that you set the persistent flag to true for all non-looping sounds when you first create them. If you fail to do this, manipulating a sound in any way by use of its slot number can have unpredictable results. This is because the sound pool automatically cleans up any sound that has finished playing and that is not set to be persistent, with the result that the slot that was returned on creation is no longer invalid and may, in the worst case scenario, refer to a completely different sound.
Example:
#include "sound_pool.bgt"
sound_pool sounds;
timer move_timer;
int pos;
void main()
{
sounds.max_distance=70;
pos=0;
int slot=sounds.play_1d("sounds/loop.wav", 100, pos, true);
while(true)
{
if(move_timer.elapsed>=200)
{
move_timer.restart();
pos++;
sounds.update_sound_1d(slot, pos);
sounds.update_sound_start_values(slot, 0, -1, 90);
}
if(pos>=100)
{
exit();
}
}
}